package com.alliky.core.utils

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction

fun addFragmentToActivity(manager: FragmentManager, fragment: Fragment?, frameId: Int) {
    val transaction: FragmentTransaction = manager.beginTransaction()
    if (fragment != null) {
        transaction.add(frameId, fragment)
    }
    transaction.commit()
}

inline fun FragmentManager.inTransaction(func: FragmentTransaction.() -> Unit) {
    val fragmentTransaction = beginTransaction()
    fragmentTransaction.func()
    fragmentTransaction.commit()
}
